import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:求俩个数的最大公约数
 * User: xwl
 * Date: 2023-03-30
 * Time: 21:12
 */
public class Test7 {
    public static void main(String[] args) {
        //输入
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            int m = scan.nextInt();
            int n = scan.nextInt();
            //处理异常输入
            if(m == 0 || n == 0) {
                System.out.println("输入有误，请重新输入");
                continue;
            }
            //辗转相除
            /*
            n/m -n/m...n%m
            18/12 -1...6
            12/6 -2...0

             */
            while(n%m != 0) {
                int temp = m;
                m = n % m;
                n = temp;
            }
            //输出
            System.out.println(m);
        }
    }
}
